package com.bs.web.rest;

import com.bs.domain.ServiceInfo;
import com.bs.service.PaltformDashService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Api(value = "platformDash")
@RestController
@RequestMapping("/api/dashboard")
public class PlatformDashResource {

    @Autowired
    private PaltformDashService paltformDashService;

    @GetMapping("loginTotal")
    public Map<String, Long> loginTotal(@RequestParam("startTime") String startTime,
                                        @RequestParam("endTime") String endTime,
                                        @RequestParam("active") String active) {

        return paltformDashService.loginTotal(startTime, endTime, active);
    }

    @GetMapping("callServiceTotal")
    public Map<String, Long> callServiceTotal(@RequestParam("startTime") String startTime,
                                              @RequestParam("endTime") String endTime,
                                              @RequestParam("active") String active) {

        return paltformDashService.callServiceTotal(startTime, endTime, active);
    }


    @GetMapping("frameTotal")
    public Map<String, Long> frameTotal(@RequestParam("startTime") String startTime,
                                        @RequestParam("endTime") String endTime,
                                        @RequestParam("active") String active) {

        return paltformDashService.frameTotal(startTime, endTime, active);
    }

    @GetMapping("asyncRouteSendTotal")
    public Map<String, Long> asyncRouteSendTotal(@RequestParam("startTime") String startTime,
                                                 @RequestParam("endTime") String endTime,
                                                 @RequestParam("active") String active) {

        return paltformDashService.asyncRouteSendTotal(startTime, endTime, active);
    }

    @GetMapping("asyncRouteReceiveTotal")
    public Map<String, Long> asyncRouteReceiveTotal(@RequestParam("startTime") String startTime,
                                                    @RequestParam("endTime") String endTime,
                                                    @RequestParam("active") String active) {

        return paltformDashService.asyncRouteReceiveTotal(startTime, endTime, active);
    }

    @GetMapping("batchTotal")
    public Map<String, Long> batchTotal(@RequestParam("startTime") String startTime,
                                        @RequestParam("endTime") String endTime,
                                        @RequestParam("active") String active) {

        return paltformDashService.batchTotal(startTime, endTime, active);
    }

    @GetMapping("callServiceLine")
    public List<ServiceInfo> callServiceLine(@RequestParam("startTime") String startTime,
                                             @RequestParam("endTime") String endTime,
                                             @RequestParam("interval") long interval,
                                             @RequestParam("active") String active) {

        return paltformDashService.callServiceLine(startTime, endTime, interval,active);
    }
    @GetMapping("mapService")
    public ArrayList<Object> mapService(@RequestParam("startTime") String startTime,
                                        @RequestParam("endTime") String endTime,
                                        @RequestParam("active") String active) {

        return paltformDashService.mapService(startTime, endTime,active);
    }

    @GetMapping("asyncRouteLine")
    public Map<String, Object> asyncRouteLine(@RequestParam("startTime") String startTime,
                                              @RequestParam("endTime") String endTime,
                                              @RequestParam("interval") long interval,
                                              @RequestParam("active") String active) {

        return paltformDashService.asyncRouteLine(startTime, endTime,interval,active);
    }
}
